package com.codedancer.campus.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.ConfessionalWallKudos;

public interface ConfessionalWallKudosMapper extends BaseMapper<ConfessionalWallKudos> {

    /**
     * 表白墙是否点赞
     *
     * @param uuid
     * @param currentLoginUuid
     * @return
     */
    default Boolean isKudos(String uuid, String currentLoginUuid) {
        LambdaQueryWrapper<ConfessionalWallKudos> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ConfessionalWallKudos::getConfessionalWallUuid, uuid);
        lambdaQueryWrapper.eq(ConfessionalWallKudos::getKudosUserUuid, currentLoginUuid);
        return selectCount(lambdaQueryWrapper) > 0;
    }

    /**
     * 表白墙取消点赞
     *
     * @param uuid
     * @param currentLoginUuid
     */
    default void cancelKudos(String uuid, String currentLoginUuid) {
        LambdaQueryWrapper<ConfessionalWallKudos> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ConfessionalWallKudos::getConfessionalWallUuid, uuid);
        lambdaQueryWrapper.eq(ConfessionalWallKudos::getKudosUserUuid, currentLoginUuid);
        delete(lambdaQueryWrapper);
    }
}
